Skip to content

Conversation

@reddevilmidzy
Copy link
Contributor

@reddevilmidzy reddevilmidzy commented Nov 19, 2025

resolve: #148467

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 19, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
9 help: consider making this binding mutable
10    |
- LL |         mut x => {
-    |         +++
+ LL |         (mut x) x => {
+    |         +++++++
13 help: to modify the original value, take a borrow instead
14    |
15 LL |         ref mut x => {

25    |
26 help: consider making this binding mutable
27    |
- LL |         E::Foo(mut x) => {
-    |                +++
+ LL |         E::Foo((mut x) x) => {
+    |                +++++++
30 help: to modify the original value, take a borrow instead
31    |
32 LL |         E::Foo(ref mut x) => {

42    |
43 help: consider making this binding mutable
44    |
- LL |         S { bar: mut x } => {
-    |                  +++
+ LL |         S { bar: (mut x) x } => {
+    |                  +++++++
47 help: to modify the original value, take a borrow instead
48    |
49 LL |         S { bar: ref mut x } => {

59    |
60 help: consider making this binding mutable
61    |
- LL |         (mut x,) => {
-    |          +++
+ LL |         ((mut x) x,) => {
+    |          +++++++
64 help: to modify the original value, take a borrow instead
65    |
66 LL |         (ref mut x,) => {

76    |
77 help: consider making this binding mutable
78    |
- LL |         [mut x,_,_] => {
-    |          +++
+ LL |         [(mut x) x,_,_] => {
+    |          +++++++
81 help: to modify the original value, take a borrow instead
82    |
83 LL |         [ref mut x,_,_] => {


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args borrowck/borrowck-match-binding-is-assignment.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/borrowck/borrowck-match-binding-is-assignment" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs:14:13
   |
LL |         x => {
   |         - first assignment to `x`
LL |             x += 1; //~ ERROR [E0384]
   |             ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         (mut x) x => {
   |         +++++++
help: to modify the original value, take a borrow instead
   |
LL |         ref mut x => {
   |         +++++++

error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs:20:13
   |
LL |         E::Foo(x) => {
   |                - first assignment to `x`
LL |             x += 1; //~ ERROR [E0384]
   |             ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         E::Foo((mut x) x) => {
   |                +++++++
help: to modify the original value, take a borrow instead
   |
LL |         E::Foo(ref mut x) => {
   |                +++++++

error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs:26:13
   |
LL |         S { bar: x } => {
   |                  - first assignment to `x`
LL |             x += 1; //~ ERROR [E0384]
   |             ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         S { bar: (mut x) x } => {
   |                  +++++++
help: to modify the original value, take a borrow instead
   |
LL |         S { bar: ref mut x } => {
   |                  +++++++

error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs:32:13
   |
LL |         (x,) => {
   |          - first assignment to `x`
LL |             x += 1; //~ ERROR [E0384]
   |             ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         ((mut x) x,) => {
   |          +++++++
help: to modify the original value, take a borrow instead
   |
LL |         (ref mut x,) => {
   |          +++++++

error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/borrowck-match-binding-is-assignment.rs:38:13
   |
LL |         [x,_,_] => {
   |          - first assignment to `x`
LL |             x += 1; //~ ERROR [E0384]
   |             ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         [(mut x) x,_,_] => {
   |          +++++++
help: to modify the original value, take a borrow instead
   |
LL |         [ref mut x,_,_] => {
   |          +++++++

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0384`.
---
9 help: consider making this binding mutable
10    |
- LL |     if let Some(mut x) = y {
-    |                 +++
+ LL |     if let Some((mut x) x) = y {
+    |                 +++++++
13 help: to modify the original value, take a borrow instead
14    |
15 LL |     if let Some(ref mut x) = y {

25    |
26 help: consider making this binding mutable
27    |
- LL |     let [mut x, ref xs_hold @ ..] = arr;
-    |          +++
+ LL |     let [(mut x) x, ref xs_hold @ ..] = arr;
+    |          +++++++
30 help: to modify the original value, take a borrow instead
31    |
32 LL |     let [ref mut x, ref xs_hold @ ..] = arr;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args borrowck/suggest-ref-mut-issue-118596.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/borrowck/suggest-ref-mut-issue-118596.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/borrowck/suggest-ref-mut-issue-118596" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/suggest-ref-mut-issue-118596.rs:4:9
   |
LL |     if let Some(x) = y {
   |                 - first assignment to `x`
LL |         x = 2; //~ ERROR cannot assign twice to immutable variable `x`
   |         ^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     if let Some((mut x) x) = y {
   |                 +++++++
help: to modify the original value, take a borrow instead
   |
LL |     if let Some(ref mut x) = y {
   |                 +++++++

error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/borrowck/suggest-ref-mut-issue-118596.rs:9:5
   |
LL |     let [x, ref xs_hold @ ..] = arr;
   |          - first assignment to `x`
LL |     x = 0; //~ ERROR cannot assign twice to immutable variable `x`
   |     ^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     let [(mut x) x, ref xs_hold @ ..] = arr;
   |          +++++++
help: to modify the original value, take a borrow instead
   |
LL |     let [ref mut x, ref xs_hold @ ..] = arr;
   |          +++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0384`.
---
9 help: consider making this binding mutable
10    |
- LL |     let &mut mut x = foo;
-    |              +++
+ LL |     let &mut (mut x) x = foo;
+    |              +++++++
13 help: to modify the original value, take a borrow instead
14    |
15 LL |     let &mut ref mut x = foo;


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args mut/mut-pattern-internal-mutability.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/mut/mut-pattern-internal-mutability.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/mut/mut-pattern-internal-mutability" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0384]: cannot assign twice to immutable variable `x`
##[error]  --> /checkout/tests/ui/mut/mut-pattern-internal-mutability.rs:5:5
   |
LL |     let &mut x = foo;
   |              - first assignment to `x`
LL |     x += 1; //~ ERROR cannot assign twice to immutable variable `x`
   |     ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     let &mut (mut x) x = foo;
   |              +++++++
help: to modify the original value, take a borrow instead
   |
LL |     let &mut ref mut x = foo;
   |              +++++++

error[E0506]: cannot assign to `*foo` because it is borrowed
##[error]  --> /checkout/tests/ui/mut/mut-pattern-internal-mutability.rs:13:5
   |
LL |     let &mut ref x = foo;
   |              ----- `*foo` is borrowed here
LL |     *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed
   |     ^^^^^^^^^ `*foo` is assigned to here but it was already borrowed
LL |     drop(x);
   |          - borrow later used here

error: aborting due to 2 previous errors

---

77    |
78 help: consider making this binding mutable
79    |
- LL |         Ok(a @ b @ mut a)
-    |                    +++
+ LL |         Ok(a @ b @ (mut a) a)
+    |                    +++++++
82 help: to modify the original value, take a borrow instead
83    |
84 LL |         Ok(a @ b @ ref mut a)


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args pattern/bindings-after-at/pat-at-same-name-both.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/bindings-after-at/pat-at-same-name-both" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0415]: identifier `a` is bound more than once in this parameter list
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:6:14
   |
LL |     fn f(a @ a @ a: ()) {}
   |              ^ used as parameter more than once

error[E0415]: identifier `a` is bound more than once in this parameter list
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:6:18
   |
LL |     fn f(a @ a @ a: ()) {}
   |                  ^ used as parameter more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:11:20
   |
LL |         Ok(a @ b @ a)
   |                    ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:13:23
   |
LL |         | Err(a @ b @ a) //~ ERROR cannot assign twice to immutable variable `a`
   |                       ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:18:13
   |
LL |     let a @ a @ a = ();
   |             ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:18:17
   |
LL |     let a @ a @ a = ();
   |                 ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:21:21
   |
LL |     let ref a @ ref a = ();
   |                     ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:23:29
   |
LL |     let ref mut a @ ref mut a = (); //~ ERROR cannot borrow value as mutable more than once at a time
   |                             ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:26:17
   |
LL |     let a @ (Ok(a) | Err(a)) = Ok(());
   |                 ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:26:26
   |
LL |     let a @ (Ok(a) | Err(a)) = Ok(());
   |                          ^ used in a pattern more than once

error: cannot borrow value as mutable more than once at a time
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:23:9
   |
LL |     let ref mut a @ ref mut a = (); //~ ERROR cannot borrow value as mutable more than once at a time
   |         ^^^^^^^^^   --------- value is mutably borrowed by `a` here
   |         |
   |         value is mutably borrowed by `a` here

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/bindings-after-at/pat-at-same-name-both.rs:13:15
   |
LL |         Ok(a @ b @ a)
   |                    - first assignment to `a`
LL |         //~^ ERROR identifier `a` is bound more than once in the same pattern
LL |         | Err(a @ b @ a) //~ ERROR cannot assign twice to immutable variable `a`
   |               ^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |         Ok(a @ b @ (mut a) a)
   |                    +++++++
help: to modify the original value, take a borrow instead
   |
LL |         Ok(a @ b @ ref mut a)
   |                    +++++++

error: aborting due to 12 previous errors

Some errors have detailed explanations: E0384, E0415, E0416.
---

21    |
22 help: consider making this binding mutable
23    |
- LL |     let [ref _x0_hold, mut _x1, ref xs_hold @ ..] = arr;
-    |                        +++
+ LL |     let [ref _x0_hold, (mut _x1) _x1, ref xs_hold @ ..] = arr;
+    |                        +++++++++
26 help: to modify the original value, take a borrow instead
27    |
28 LL |     let [ref _x0_hold, ref mut _x1, ref xs_hold @ ..] = arr;

85    |
86 help: consider making this binding mutable
87    |
- LL |     let (ref _x0, mut _x1, ref _x2, ..) = tup;
-    |                   +++
+ LL |     let (ref _x0, (mut _x1) _x1, ref _x2, ..) = tup;
+    |                   +++++++++
90 help: to modify the original value, take a borrow instead
91    |
92 LL |     let (ref _x0, ref mut _x1, ref _x2, ..) = tup;

Note: some mismatched output was normalized before being compared
- LL |     let [ref _x0_hold, (mut _x1) _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
+ LL |     let [ref _x0_hold, (mut _x1) _x1, ref xs_hold @ ..] = arr;
+    |                        +++++++++
+ LL |     let (ref _x0, (mut _x1) _x1, ref _x2, ..) = tup;
+    |                   +++++++++


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args pattern/move-ref-patterns/borrowck-move-ref-pattern.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0505]: cannot move out of `arr[..]` because it is borrowed
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:8:24
   |
LL |     let mut arr = [U, U, U, U, U];
   |         ------- binding `arr` declared here
LL |     let hold_all = &arr;
   |                    ---- borrow of `arr` occurs here
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                        ^^^ move out of `arr[..]` occurs here
LL |     _x1 = U; //~ ERROR cannot assign twice to immutable variable `_x1`
LL |     drop(hold_all);
   |          -------- borrow later used here

error[E0384]: cannot assign twice to immutable variable `_x1`
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:9:5
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                        --- first assignment to `_x1`
LL |     _x1 = U; //~ ERROR cannot assign twice to immutable variable `_x1`
   |     ^^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     let [ref _x0_hold, (mut _x1) _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                        +++++++++
help: to modify the original value, take a borrow instead
   |
LL |     let [ref _x0_hold, ref mut _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                        +++++++

error[E0505]: cannot move out of `arr[..]` because it is borrowed
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:11:10
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |          ------------ borrow of `arr[..]` occurs here
...
LL |     let [_x0, ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |          ^^^ move out of `arr[..]` occurs here
LL |     drop(_x0_hold);
   |          -------- borrow later used here

error[E0502]: cannot borrow `arr[..]` as mutable because it is also borrowed as immutable
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:13:16
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                             ----------- immutable borrow occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                ^^^^^^^^^^^ mutable borrow occurs here
...
LL |     drop(xs_hold);
   |          ------- immutable borrow later used here

error[E0505]: cannot move out of `arr[..]` because it is borrowed
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:13:29
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                             ----------- borrow of `arr[..]` occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                             ^^^ move out of `arr[..]` occurs here
...
LL |     drop(xs_hold);
   |          ------- borrow later used here

error[E0505]: cannot move out of `arr[..]` because it is borrowed
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:13:34
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr; //~ ERROR cannot move out of `arr[..]`
   |                             ----------- borrow of `arr[..]` occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                                  ^^^^^^^ move out of `arr[..]` occurs here
...
LL |     drop(xs_hold);
   |          ------- borrow later used here

error[E0384]: cannot assign twice to immutable variable `_x1`
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:23:5
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |                   --- first assignment to `_x1`
LL |     _x1 = U; //~ ERROR cannot assign twice to immutable variable
   |     ^^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     let (ref _x0, (mut _x1) _x1, ref _x2, ..) = tup;
   |                   +++++++++
help: to modify the original value, take a borrow instead
   |
LL |     let (ref _x0, ref mut _x1, ref _x2, ..) = tup;
   |                   +++++++

error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:24:20
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |          ------- immutable borrow occurs here
LL |     _x1 = U; //~ ERROR cannot assign twice to immutable variable
LL |     let _x0_hold = &mut tup.0; //~ ERROR cannot borrow `tup.0` as mutable because it is also
   |                    ^^^^^^^^^^ mutable borrow occurs here
LL |     let (ref mut _x0_hold, ..) = tup; //~ ERROR cannot borrow `tup.0` as mutable because it is also
LL |     *_x0 = U; //~ ERROR cannot assign to `*_x0`, which is behind a `&` reference
   |     -------- immutable borrow later used here

error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:25:10
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |          ------- immutable borrow occurs here
...
LL |     let (ref mut _x0_hold, ..) = tup; //~ ERROR cannot borrow `tup.0` as mutable because it is also
   |          ^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL |     *_x0 = U; //~ ERROR cannot assign to `*_x0`, which is behind a `&` reference
   |     -------- immutable borrow later used here

error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:26:5
   |
LL |     *_x0 = U; //~ ERROR cannot assign to `*_x0`, which is behind a `&` reference
   |     ^^^^^^^^ `_x0` is a `&` reference, so it cannot be written to
   |
help: consider changing this to be a mutable reference
   |
LL |     let (ref mut _x0, _x1, ref _x2, ..) = tup;
   |              +++

error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:27:5
   |
LL |     *_x2 = U; //~ ERROR cannot assign to `*_x2`, which is behind a `&` reference
   |     ^^^^^^^^ `_x2` is a `&` reference, so it cannot be written to
   |
help: consider changing this to be a mutable reference
   |
LL |     let (ref _x0, _x1, ref mut _x2, ..) = tup;
   |                            +++

error[E0382]: use of moved value: `tup.1`
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:28:10
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |                   --- value moved here
...
LL |     drop(tup.1); //~ ERROR use of moved value: `tup.1`
   |          ^^^^^ value used here after move
   |
   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
   |
LL |     let (ref _x0, ref _x1, ref _x2, ..) = tup;
   |                   +++

error[E0382]: borrow of moved value: `tup.1`
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:29:20
   |
LL |     drop(tup.1); //~ ERROR use of moved value: `tup.1`
   |          ----- value moved here
LL |     let _x1_hold = &tup.1; //~ ERROR borrow of moved value: `tup.1`
   |                    ^^^^^^ value borrowed here after move
   |
   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait

error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:31:20
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- mutable borrow occurs here
LL |     let _x3_hold = &tup.3; //~ ERROR cannot borrow `tup.3` as immutable
   |                    ^^^^^^ immutable borrow occurs here
...
LL |     drop(_x3);
   |          --- mutable borrow later used here

error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:32:20
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- first mutable borrow occurs here
LL |     let _x3_hold = &tup.3; //~ ERROR cannot borrow `tup.3` as immutable
LL |     let _x3_hold = &mut tup.3; //~ ERROR cannot borrow `tup.3` as mutable more
   |                    ^^^^^^^^^^ second mutable borrow occurs here
...
LL |     drop(_x3);
   |          --- first borrow later used here

error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:33:14
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- first mutable borrow occurs here
...
LL |     let (.., ref mut _x4_hold) = tup; //~ ERROR cannot borrow `tup.3` as mutable more
   |              ^^^^^^^^^^^^^^^^ second mutable borrow occurs here
LL |     let (.., ref _x4_hold) = tup; //~ ERROR cannot borrow `tup.3` as immutable
LL |     drop(_x3);
   |          --- first borrow later used here

error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:34:14
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- mutable borrow occurs here
...
LL |     let (.., ref _x4_hold) = tup; //~ ERROR cannot borrow `tup.3` as immutable
   |              ^^^^^^^^^^^^ immutable borrow occurs here
LL |     drop(_x3);
   |          --- mutable borrow later used here

error[E0382]: use of moved value: `tup`
##[error]  --> /checkout/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs:43:14
   |
LL |     let mut tup = (U, U, U);
   |         ------- move occurs because `tup` has type `(U, U, U)`, which does not implement the `Copy` trait
LL |     let c1 = || {
   |              -- value moved into closure here
LL |         let (ref _x0, _x1, _) = tup;
   |                                 --- variable moved due to use in closure
LL |     };
LL |     let c2 = || {
   |              ^^ value used here after move
LL |         //~^ ERROR use of moved value
LL |         let (ref mut _x0, _, _x2) = tup;
   |                                     --- use occurs due to use in closure

error: aborting due to 18 previous errors

Some errors have detailed explanations: E0382, E0384, E0499, E0502, E0505, E0594.
For more information about an error, try `rustc --explain E0382`.
------------------------------------------

---- [ui] tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs stdout end ----
---- [ui] tests/ui/pattern/mut-ref-mut-2021.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/mut-ref-mut-2021/mut-ref-mut-2021.stderr`
diff of stderr:

8    |
9 help: consider making this binding mutable
10    |
- LL |     let Foo(mut a) = Foo(0);
-    |             +++
+ LL |     let Foo((mut a) a) = Foo(0);
+    |             +++++++
13 help: to modify the original value, take a borrow instead
14    |
15 LL |     let Foo(ref mut a) = Foo(0);


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args pattern/mut-ref-mut-2021.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/pattern/mut-ref-mut-2021.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/pattern/mut-ref-mut-2021" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:9:5
   |
LL |     let Foo(a) = Foo(0);
   |             - first assignment to `a`
LL |     a = 42; //~ ERROR [E0384]
   |     ^^^^^^ cannot assign twice to immutable variable
   |
help: consider making this binding mutable
   |
LL |     let Foo((mut a) a) = Foo(0);
   |             +++++++
help: to modify the original value, take a borrow instead
   |
LL |     let Foo(ref mut a) = Foo(0);
   |             +++++++

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:15:5
   |
LL |     let Foo(ref a) = Foo(0);
   |             ----- first assignment to `a`
LL |     a = &42; //~ ERROR [E0384]
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:21:5
   |
LL |     let Foo(ref mut a) = Foo(0);
   |             --------- first assignment to `a`
LL |     a = &mut 42; //~ ERROR [E0384]
   |     ^^^^^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:27:5
   |
LL |     let Foo(a) = &Foo(0);
   |             - first assignment to `a`
LL |     a = &42; //~ ERROR [E0384]
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:33:5
   |
LL |     let Foo(ref a) = &Foo(0);
   |             ----- first assignment to `a`
LL |     a = &42; //~ ERROR [E0384]
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:39:5
   |
LL |     let Foo(a) = &mut Foo(0);
   |             - first assignment to `a`
LL |     a = &mut 42; //~ ERROR [E0384]
   |     ^^^^^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:45:5
   |
LL |     let Foo(ref a) = &mut Foo(0);
   |             ----- first assignment to `a`
LL |     a = &42; //~ ERROR [E0384]
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0384]: cannot assign twice to immutable variable `a`
##[error]  --> /checkout/tests/ui/pattern/mut-ref-mut-2021.rs:51:5
   |
LL |     let Foo(ref mut a) = &mut Foo(0);
   |             --------- first assignment to `a`
LL |     a = &mut 42; //~ ERROR [E0384]
   |     ^^^^^^^^^^^ cannot assign twice to immutable variable

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0384`.
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compiler incorrectly suggest converting &x ->&mut x instead of &(mut x) when matching on a &T(T : Copy)

3 participants